<?php

namespace app\admin\controller\wechat;

use app\admin\controller\Base;
use think\Db;

/**
 * 用户组管理
 * Class GroupController
 * @package app\admin\controller\auth
 */
class Wxsend extends Base
{
    /**
     * 主页面
     * @return mixed
     */
    public function index()
    {
        return view();
    }

    public function lists()
    {
        $map = array();
        $post = $this->request->param();
        $data['count'] = Db::name('wx_msg')
            ->where($map)
            ->count();
        $data['data'] = Db::name('wx_msg')
            ->where($map)
            // ->fetchSql(true)
            ->order('id desc')
            ->page($post['page'], $post['limit'])->select();
        foreach ($data['data'] as &$info) {
            $info['c_time'] = date('Y-m-d H:i:s', $info['c_time']);
            $info['info']=strip_tags($info['info']);
        }
        if ($data['count'] > 0 && $data['data']) {
            $data['msg'] = '获取成功';
        } else {
            $data['msg'] = '获取数据为空';
        }
        $data['code'] = 0;
        return json($data);
    }

    public function info()
    {
        $this->assign('msg_id',input('id'));
        return view();
    }

    public function info_lists()
    {

        $map = array();
        $post = $this->request->param();
        $map[]=['msg_id','=',$post['msg_id']];
        $data['count'] = Db::view('wx_msg_info','id,msg_id,uid,status,msgid')
            ->view('admin','nickname','wx_msg_info.uid=admin.id')
            ->where($map)
            ->count();
        $data['data'] =  Db::view('wx_msg_info','id,msg_id,uid,status,msgid')
            ->view('admin','nickname','wx_msg_info.uid=admin.id')
            ->where($map)
            // ->fetchSql(true)
            ->order('id desc')
            ->page($post['page'], $post['limit'])->select();
        $status = config('param.wx_msg_status');
        foreach ($data['data'] as &$info) {
            $info['status'] = $status[$info['status']];
        }
        if ($data['count'] > 0 && $data['data']) {
            $data['msg'] = '获取成功';
        } else {
            $data['msg'] = '获取数据为空';
        }
        $data['code'] = 0;
        return json($data);
    }

}